#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'

template<typename T=int>
inline T read() {
    T x;
    cin >> x;
    return x;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    map<string, int> m;//单词统计 map使用
    for (string w; cin >> w;) {
        m[w]++;
    }
    for (auto e:m) {
        cout << e.first << " " << e.second << endl;
    }

    return 0;
}
